
int incomingByte = 0;	// for incoming serial data

void setup()
{
  Serial.begin(9600);
  backlightOn();
  
}

void loop()
{  
  


  if (Serial.available() > 0) {
    // read the incoming byte:
    incomingByte = Serial.read();
 delay(100);
    // say what you got:
    selectLineOne();
     delay(100);
    Serial.print("I received: ");
    selectLineTwo();
    delay(100);
    Serial.print(incomingByte, BYTE);
     delay(100);
  }
}



void selectLineOne(){  //puts the cursor at line 0 char 0.
  Serial.print(0xFE, BYTE);   //command flag
  Serial.print(128, BYTE);    //position
}
void selectLineTwo(){  //puts the cursor at line 0 char 0.
  Serial.print(0xFE, BYTE);   //command flag
  Serial.print(192, BYTE);    //position
}
void clearLCD(){
  Serial.print(0xFE, BYTE);   //command flag
  Serial.print(0x01, BYTE);   //clear command.
}
void backlightOn(){  //turns on the backlight
  Serial.print(0x7C, BYTE);   //command flag for backlight stuff
  Serial.print(157, BYTE);    //light level.
}
void backlightOff(){  //turns off the backlight
  Serial.print(0x7C, BYTE);   //command flag for backlight stuff
  Serial.print(128, BYTE);     //light level for off.
}
void serCommand(){   //a general function to call the command flag for issuing all other commands   
  Serial.print(0xFE, BYTE);
}
